package com.future.lock.me.order.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.future.lock.R;
import com.future.lock.me.order.entity.bean.OrderListInfoBean;

import java.util.List;

/**
 * Created by yzh on 2017/12/17.
 */

public class OrderInfoListAdapter extends BaseQuickAdapter<OrderListInfoBean, BaseViewHolder> {

    public OrderInfoListAdapter(@LayoutRes int layoutResId, @Nullable List<OrderListInfoBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderListInfoBean item) {
        helper.setText(R.id.orderNum, item.getOrder_sn());
        helper.setText(R.id.title, item.getGoods_name());
        helper.setText(R.id.price, String.format("¥%.2f", item.getOrder_amount()));
        helper.setText(R.id.operateType, item.getStatusStr());
        helper.setTextColor(R.id.operateType, item.getStatusTextColor());
        helper.setText(R.id.operateButton, item.getStatusOperateStr());
        helper.setChecked(R.id.operateButton, item.getStatus() == OrderListInfoBean.ORDER_STATUS_WAIT_TO_PAY);
        helper.setVisible(R.id.operateButton, item.getStatus() == OrderListInfoBean.ORDER_STATUS_WAIT_TO_PAY || item.getStatus() == OrderListInfoBean.ORDER_STATUS_WAIT_FOR_DELIVERY);
        helper.addOnClickListener(R.id.operateButton);
        Glide.with(mContext)
                .load(item.getHead_img())
                .dontAnimate()
                .into((ImageView) helper.getView(R.id.icon));
    }
}
